package top.zkh.login;

import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import com.java1234.util.DbUtil;
import com.java1234.util.StringUtil;
import com.java1234.dao.animalDao;
import com.java1234.model.animal;
public class userfindServlet extends HttpServlet{
	private DbUtil dbUtil=new DbUtil();
	private animalDao animaldao=new animalDao();
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding ("utf-8");
		resp.setContentType("text/html;carset=utf-8");	
		String key1 = req.getParameter("ID");
		String key2 = req.getParameter("animalName");
			List<animal> animal2 = new ArrayList<animal>();
			animal animal1 = new animal();
			animal1.setId((key1));
			animal1.setAnimalName(key2);
			Connection con=null;
			try {
				con=dbUtil.getCon();
				if(StringUtil.isEmpty(key1)&&StringUtil.isEmpty(key2))
					animal2=animaldao.find3(con, animal1);
				else if(StringUtil.isEmpty(key1))
					animal2=animaldao.find2(con, animal1);
				else
					animal2=animaldao.find1(con,animal1);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			};
			
			req.setAttribute("aList", animal2);		
			req.getRequestDispatcher("userfind.jsp").forward(req, resp);
		}			
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		this.doGet(req, resp);
	}
}
